import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.FlowLayout;
import javax.swing.BoxLayout;
import java.awt.GridLayout;


@SuppressWarnings("serial")
public class MainWindow extends JFrame {

	private JPanel contentPane;
	private JTextField textField;
	private JButton btnClose;
	private JButton btnNewUser;
	private JButton btnChart;
	private JButton btnEnterWeight;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					MainWindow frame = new MainWindow();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public MainWindow() {
		setTitle("MAIN WINDOW");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		
		JPanel panel = new JPanel();
		contentPane.add(panel, BorderLayout.CENTER);
		
		textField = new JTextField();
		panel.add(textField);
		textField.setColumns(10);
		
		JPanel panel_1 = new JPanel();
		contentPane.add(panel_1, BorderLayout.SOUTH);
		
		btnClose = new JButton("Close");
		panel_1.add(btnClose);
		
		JPanel panel_2 = new JPanel();
		contentPane.add(panel_2, BorderLayout.WEST);
		panel_2.setLayout(new GridLayout(5, 1, 0, 0));
		
		btnNewUser = new JButton("New User");
		panel_2.add(btnNewUser);
		
		btnChart = new JButton("Chart");
		panel_2.add(btnChart);

		btnEnterWeight = new JButton("Enter Weight");
		panel_2.add(btnEnterWeight);
	}
	
	// hooks for the view to register listeners
	public void setCloseActionListener(ActionListener listener) {
		btnClose.addActionListener(listener);
	}

	public void setLoginActionListener(ActionListener listener) {
		btnNewUser.addActionListener(listener);
	}

	public void setChartActionListener(ActionListener listener) {
		btnChart.addActionListener(listener);
	}

	public void setEnterWeightActionListener(ActionListener listener) {
		btnEnterWeight.addActionListener(listener);
	}
}
